package com.sinven.controller.manage;

import com.sinven.common.ActionResult;
import com.sinven.pojo.Category;
import com.sinven.service.CategoryService;
import com.sinven.util.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/manage")
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    @GetMapping("/categories/{code}")
    public ActionResult<Category> getCategory(@PathVariable("code")String code){
        Category category = categoryService.queryCategoryByCode(code);
        return ResultUtil.success(category);
    }
}
